package hn.cch.neo4j.entity;

import com.fasterxml.jackson.annotation.JsonIdentityInfo;
import com.voodoodyne.jackson.jsog.JSOGGenerator;
import org.neo4j.ogm.annotation.GraphId;
import org.neo4j.ogm.annotation.NodeEntity;
import org.neo4j.ogm.annotation.Relationship;

import java.util.ArrayList;
import java.util.List;

/**
 * 电影
 *
 * @author CCH
 * @version 2018.07.10
 */

@JsonIdentityInfo(generator = JSOGGenerator.class)
@NodeEntity
public class Movie {
    @GraphId
    private Long id;
    private String name;
    private String date;

    //关系类型和关系方向
    @Relationship(type = "ACTS_IN", direction = Relationship.INCOMING)
    List<Role> roles = new ArrayList<>();

    //添加
    public Role addRole(String roleName, Actor actor) {
        Role role = new Role(roleName, actor, this);
        this.roles.add(role);
        return role;
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public List<Role> getRoles() {
        return roles;
    }

    public void setRoles(List<Role> roles) {
        this.roles = roles;
    }

    public String getDate() {
        return date;
    }

    public void setDate(String date) {
        this.date = date;
    }
}
